|
|
 |
|
|
|
|
lty = -n1_over_n2 * nly - normal_factor * Ny
ltz = -n1_over_n2 * nlz - normal_factor * Nz
' Calculate V dot LT. VdotLT = Vx * ltx + Vy * lty + Vz * ltz
' See if V and LT point in generally
' the same direction. If VdotLT > 0 Then ' Calculate V dot LT to the TransN. transmitted_factor = VdotLT ^ TransN
' Add the direct transmitted component. total_r = total_r + Ktr * light_source.Ir * _
transmitted_factor
total_g = total_g + Ktg * light_source.Ig * _
transmitted_factor
total_b = total_b + Ktb * light_source.Ib * _
transmitted_factor
End If
End If
Next light_source
: ' **************************
' * Indirectly Transmitted *
' ************************** ' See if the surface is transparent. If (depth > 1) And is_transparent Then
' Find VT, the viewing transmission vector. cos1 = Abs(VdotN)
n1_over_n2 = n1 / n2
cos2 = Sqr(1 - (1 - cos1 * cos1) * n1_over_n2 * _
n1_over_n2)
' Note that the incident vector I = -V. normal_factor = cos2 - n1_over_n2 * cos1
vtx = -n1_over_n2 * Vx - normal_factor * Nx
vty = -n1_over_n2 * Vy - normal_factor * Ny
vtz = -n1_over_n2 * Vz - normal_factor * Nz
TraceRay False, depth - 1, target_object, _
px, py, pz, vtx, vty, vtz, _
r_tran, g_tran, b_tran
' Add the indirectly transmitted components. total_r = total_r + Ktr * r_tran
total_g = total_g + Ktg * g_tran
total_b = total_b + Ktb * b_tran
End If
:
End Sub |
|
|
|
|
|